'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, io } = app;

  // 文章
  router.get('/getRecommend', controller.articles.getRecommend);
  router.get('/initialEditor', controller.articles.initialEditor);
  router.get('/getDraft', controller.articles.getDraft);
  router.get('/getPosts', controller.articles.getPosts);
  router.get('/getFavorited', controller.articles.getFavorited);
  router.get('/getReview', controller.articles.getReview);
  router.get('/getAllArticles', controller.articles.getAllArticles);
  router.get('/getPublishedArticleById', controller.articles.getPublishedArticleById);
  router.get('/getArticleById', controller.articles.getArticleById);
  router.get('/getPublishedArticlesByType', controller.articles.getPublishedArticlesByType);
  router.get('/deleteArticle', controller.articles.deleteArticle);
  router.get('/publish', controller.articles.publish);
  router.get('/search', controller.articles.search);
  router.post('/updateArticleById', controller.articles.updateArticleById);
  router.post('/commentArticle', controller.articles.commentArticle);
  router.post('/commentReply', controller.articles.commentReply);
  router.post('/likeArticleById', controller.articles.likeArticleById);
  router.post('/favoritedArticleById', controller.articles.favoritedArticleById);

  // 用户
  router.post('/signIn', controller.user.signIn);
  router.post('/signUp', controller.user.signUp);
  router.get('/getAllUsers', controller.user.getAllUsers);
  router.get('/getLikedMessageByUserId', controller.user.getLikedMessageByUserId);
  router.get('/getCommentArticleMessageByUserId', controller.user.getCommentArticleMessageByUserId);
  router.get('/getFocusMessageByUserId', controller.user.getFocusMessageByUserId);
  router.get('/getSystemMessageByUserId', controller.user.getSystemMessageByUserId);
  // 通用
  router.post('/fileUpload', controller.base.fileUpload);

  // socket.io
  io.of('/').route('exchange', io.controller.message.exchange);
};
